<?php
class User
{

	public function process()
	{
		
	}
	public function login()
	{
		$userName = Controller::$input['username'];
		$password = Controller::$input['password'];
		
		$valid = false;
		if( $userName && $password ) 
		{
			$valid = Controller::$configs['accounts'][$userName] == $password;
		}
	
		if( $valid == true ) 
		{
			$_SESSION['user'][$userName] = md5($userName.$password);
		}
	}
	
	public function logout()
	{
		unset( $_SESSION['user'] );
		header("Location: index.php");
	}
	
	public static function isLoggedIn()
	{
		return isset( $_SESSION['user'] );
	}
	
	public static function isAdmin()
	{
		return isset( $_SESSION['user']['admin'] ) ;
	}
	
}
?>